package blackspire.action.upload;

import java.util.List;

import blackspire.model.character.WOWCharacter;
import blackspire.service.character.CharacterService;

import com.opensymphony.xwork2.ActionSupport;

public class UploadCharacterAction extends ActionSupport
{
	private String name;
	private String realm;
	private List<WOWCharacter> characters;
	private String result;

	private CharacterService characterService;

	public UploadCharacterAction(CharacterService characterService)
	{
		this.characterService = characterService;
	}

	public String execute() throws Exception
	{
		characterService.syncCharacterWithArmory(name, realm);
		
		return SUCCESS;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getRealm()
	{
		return realm;
	}

	public void setRealm(String realm)
	{
		this.realm = realm;
	}

	public List<WOWCharacter> getCharacters()
	{
    	if (characters == null)
    	{
    		this.characters = characterService.findAll();
    	}
    	
    	return characters;
	}

	public String getResult()
	{
		return result;
	}

	public void setResult(String result)
	{
		this.result = result;
	}

}